/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.intec.matsab.persistence;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author matilde
 */
@Entity
@Table(name = "Trimestre")
@NamedQueries({@NamedQuery(name = "Trimestre.findByIdTrimestre", query = "SELECT t FROM Trimestre t WHERE t.idTrimestre = :idTrimestre"), 
@NamedQuery(name = "Trimestre.findByFechaInicio", query = "SELECT t FROM Trimestre t WHERE t.fechaInicio = :fechaInicio"), 
@NamedQuery(name = "Trimestre.findByFechaFinal", query = "SELECT t FROM Trimestre t WHERE t.fechaFinal = :fechaFinal"),
@NamedQuery(name = "Trimestre.AllTrimestres", query = "SELECT t FROM Trimestre t")})
public class Trimestre implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue
    @Column(name = "idTrimestre", nullable = false)
    private Integer idTrimestre;
    
    @Column(name = "fecha_inicio", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date fechaInicio;
    
    @Column(name = "fecha_final", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date fechaFinal;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "trimestre")
    private Collection<Seccion> seccionCollection;
    @JoinColumn(name = "idEstado", referencedColumnName = "idEstado")
    @ManyToOne
    private Estado idEstado;

    public Trimestre() {
    }

    public Trimestre(Integer idTrimestre) {
        this.idTrimestre = idTrimestre;
    }

    public Trimestre(Integer idTrimestre, Date fechaInicio, Date fechaFinal) {
        this.idTrimestre = idTrimestre;
        this.fechaInicio = fechaInicio;
        this.fechaFinal = fechaFinal;
    }

    public Integer getIdTrimestre() {
        return idTrimestre;
    }

    public void setIdTrimestre(Integer idTrimestre) {
        this.idTrimestre = idTrimestre;
    }

    public Date getFechaInicio() {
        return fechaInicio;
    }

    public void setFechaInicio(Date fechaInicio) {
        this.fechaInicio = fechaInicio;
    }

    public Date getFechaFinal() {
        return fechaFinal;
    }

    public void setFechaFinal(Date fechaFinal) {
        this.fechaFinal = fechaFinal;
    }

    public Collection<Seccion> getSeccionCollection() {
        return seccionCollection;
    }

    public void setSeccionCollection(Collection<Seccion> seccionCollection) {
        this.seccionCollection = seccionCollection;
    }

    public Estado getIdEstado() {
        return idEstado;
    }

    public void setIdEstado(Estado idEstado) {
        this.idEstado = idEstado;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTrimestre != null ? idTrimestre.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Trimestre)) {
            return false;
        }
        Trimestre other = (Trimestre) object;
        if ((this.idTrimestre == null && other.idTrimestre != null) || (this.idTrimestre != null && !this.idTrimestre.equals(other.idTrimestre))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.intec.matsab.persistence.Trimestre[idTrimestre=" + idTrimestre + "]";
    }

}
